Dim eltDrive
DIM eltDB
strComputer = "."
DIM delTAF
DIM delLCK

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

eltDrive="D:"
For Each objItem in colItems
 if ucase(objItem.Name) = "ELTDRIVE" then eltDrive = objItem.VariableValue
next

eltDB = "type ALL or a database name here"
eltDB = InputBox("WARNING: DO NOT RUN THIS PROGRAM ON DATABASES THAT ARE IN USE!" & VbCrLf & VbCrLf & "Type 'ALL' to delete all Lck & Taf files or enter a database name: ie; LIVE, FALL, SS, SN or WI"," Delete LCK & TAF files",eltDB)
eltDB = ucase(eltDB)

if IsEmpty(eltDB) then 
	msgbox "cancelled"
 elseif Len(eltDB) = 0 then
 	msgbox "cancelled"
 elseif left(ucase(eltDB),1) = " " then
 	msgbox "Must enter valid DB name or ALL"
 else 
 if CheckFolderExists (eltDB) <> True then
    msgbox "'"& eltDrive & "\ELT\"& ucase(eltDB) & "'  does not exist! - Please try again"
    else

if eltDB <> "ALL" then delTAF = "del " & eltDrive & "\elt\" & eltDB & "\vistamu.taf /s"
if eltDB <> "ALL" then delLCK = "del " & eltDrive & "\elt\" & eltDB & "\*.lck /s"

if eltDB = "ALL" then delTAF = "del " & eltDrive & "\elt\vistamu.taf /s"
if eltDB = "ALL" then delLCK = "del " & eltDrive & "\elt\*.lck /s"

WshShell.Run ("cmd /c " & delTAF)
WshShell.Run ("cmd /c " & delLCK)

if eltDB = "ALL" then msgbox "All LCK and TAF files have been deleted"
if eltDB <> "ALL" then msgbox "All LCK and TAF files have been deleted from: " & ucase(eltDB)
end if
end if


'********************************************************************
'************************ F U N C T I O N S *************************
'********************************************************************

Function CheckFolderExists(dbTO)

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
  CheckFolderExists = True
  if dbTO = "ALL" then Exit Function
    If fso.FolderExists(eltDrive & "\elt\" & dbTO) = False Then 
      CheckFolderExists = False
      Exit Function
    End if
  Set fso = Nothing

End Function